package com.milling.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.milling.common.annotation.Log;
import com.milling.common.core.controller.BaseController;
import com.milling.common.core.domain.AjaxResult;
import com.milling.common.enums.BusinessType;
import com.milling.business.domain.WmsSortingInstockHistory;
import com.milling.business.service.IWmsSortingInstockHistoryService;
import com.milling.common.utils.poi.ExcelUtil;
import com.milling.common.core.page.TableDataInfo;

/**
 * 分拣入库历史Controller
 *
 * @author X
 * @date 2025-06-05
 */
@RestController
@RequestMapping("/business/sortingInstockHistory")
public class WmsSortingInstockHistoryController extends BaseController
{
    @Autowired
    private IWmsSortingInstockHistoryService wmsSortingInstockHistoryService;

    /**
     * 查询分拣入库历史列表
     */
    @PreAuthorize("@ss.hasPermi('business:sortingInstockHistory:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsSortingInstockHistory wmsSortingInstockHistory)
    {
        startPage();
        List<WmsSortingInstockHistory> list = wmsSortingInstockHistoryService.selectWmsSortingInstockHistoryList(wmsSortingInstockHistory);
        return getDataTable(list);
    }

    /**
     * 导出分拣入库历史列表
     */
    @PreAuthorize("@ss.hasPermi('business:sortingInstockHistory:export')")
    @Log(title = "分拣入库历史", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsSortingInstockHistory wmsSortingInstockHistory)
    {
        List<WmsSortingInstockHistory> list = wmsSortingInstockHistoryService.selectWmsSortingInstockHistoryList(wmsSortingInstockHistory);
        ExcelUtil<WmsSortingInstockHistory> util = new ExcelUtil<WmsSortingInstockHistory>(WmsSortingInstockHistory.class);
        util.exportExcel(response, list, "分拣入库历史数据");
    }

    /**
     * 获取分拣入库历史详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:sortingInstockHistory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wmsSortingInstockHistoryService.selectWmsSortingInstockHistoryById(id));
    }

    /**
     * 新增分拣入库历史
     */
    @PreAuthorize("@ss.hasPermi('business:sortingInstockHistory:add')")
    @Log(title = "分拣入库历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsSortingInstockHistory wmsSortingInstockHistory)
    {
        return toAjax(wmsSortingInstockHistoryService.insertWmsSortingInstockHistory(wmsSortingInstockHistory));
    }

    /**
     * 修改分拣入库历史
     */
    @PreAuthorize("@ss.hasPermi('business:sortingInstockHistory:edit')")
    @Log(title = "分拣入库历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsSortingInstockHistory wmsSortingInstockHistory)
    {
        return toAjax(wmsSortingInstockHistoryService.updateWmsSortingInstockHistory(wmsSortingInstockHistory));
    }

    /**
     * 删除分拣入库历史
     */
    @PreAuthorize("@ss.hasPermi('business:sortingInstockHistory:remove')")
    @Log(title = "分拣入库历史", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsSortingInstockHistoryService.deleteWmsSortingInstockHistoryByIds(ids));
    }
}
